package com.pro.controller;

import com.pro.pojo.JsCarousel;
import com.pro.pojo.JsonData;
import com.pro.service.JsCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName:JsJsCarouselController
 * Package:com.pro.controller
 * Description:
 *
 * @Date:2022/1/25 19:05
 * @Author: XJR
 */
@RequestMapping("/JsCarousel")
@RestController
public class JsCarouselController {

    @Autowired
    private JsCarouselService service;

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/1/26
     * @Content:查看轮播图列表详情
     */
    @RequestMapping("/selectJsCarousel")
    public JsonData selectJsCarousel(String imgType, String display,Integer limit,Integer page){
        List<JsCarousel> jsCarousels = service.selectJsCarousel(imgType, display,limit,page);
        Integer count = service.countJsCarousel(imgType, display);
        return jsCarousels!=null?JsonData.buildSuccess(jsCarousels,count):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/2/2
     * @Content:通过id查询轮播图详细信息
     */
    @RequestMapping("/selectJsCarouselById")
    public JsonData selectJsCarouselById(Integer carouselId){
        JsCarousel jsCarousel = service.selectJsCarouselById(carouselId);
        return jsCarousel!=null?JsonData.buildSuccess(jsCarousel):JsonData.buildError("服务器发生错误");
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/2/2
     * @Content:编辑轮播图信息
     */
    @RequestMapping("/updateJsCarousel")
    public Boolean updateJsCarousel(JsCarousel jsCarousel){
        Boolean updateBoolean = service.updateJsCarousel(jsCarousel);
        return updateBoolean;
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/2/2
     * @Content:通过id删除轮播图
     */
    @RequestMapping("/delJsCarouselById")
    public Boolean delJsCarouselById(Integer carouselId){
        Boolean delBoolean = service.delJsCarouselById(carouselId);
        return delBoolean;
    };

    /**
     * @Description:
     * @Author: XJR
     * @Date: 2022/2/2
     * @Content:添加轮播图
     */
    @RequestMapping("/addJsCarousel")
    public Boolean addJsCarousel(JsCarousel jsCarousel){
        Boolean addBoolean = service.addJsCarousel(jsCarousel);
        return addBoolean;
    };
}
